package persistence.dto;

import common.util.DateUtils;
import java.util.Calendar;
import core.Item;

public class ItemDTO
{
	
	private int id;
	private String barcode;
	private Calendar entryDate;
	private Calendar exitTime;
	private Calendar expirationDate;
	private int productID;
	private int parentContainerID;
	private boolean removed;
	
	/**
	 * converts an item into a DTO object
	 * @param i the item to be converted to a DTO
	 */
	public ItemDTO(int id,String barcode,Calendar entryDate, 
			Calendar exitTime, Calendar expirationDate, 
			int productID, int parentContainerID, boolean removed)
	{
		this.id = id;
		this.barcode = barcode;
		this.entryDate = entryDate;
		this.exitTime = exitTime;
		this.expirationDate = expirationDate;
		this.productID = productID;
		this.parentContainerID = parentContainerID;
		this.removed = removed;
	}
        /**
	 * converts an item into a DTO object, id not set
	 * @param i the item to be converted to a DTO
	 */
	public ItemDTO(String barcode,Calendar entryDate, 
			Calendar exitTime, Calendar expirationDate, 
			int productID, int parentContainerID, boolean removed)
	{
		this.barcode = barcode;
		this.entryDate = entryDate;
		this.exitTime = exitTime;
		this.expirationDate = expirationDate;
		this.productID = productID;
		this.parentContainerID = parentContainerID;
        this.removed = removed;
	}
        
        public void setId(int id)
        {
            this.id = id;
        }

	public boolean getRemovedFlag()
	{
		return removed;
	}
	
	/**
	 * gets the items id
	 * @return returns the unique id assigned to the item
	 */
	public int getId()
	{
		return id;
	}

	/**
	 * gets the item's barcode
	 * @return
	 */
	public String getBarcode()
	{
		return barcode;
	}

	/**
	 * gets the entry date of the item
	 * @return
	 */
	public String getEntryDate()
	{
            if(entryDate == null)
            {
                return "";
            }
		return DateUtils.formatDateTime(entryDate.getTime());
	}
	
	public Calendar getEntryDateCal()
	{
		return entryDate;
	}

	/**
	 * gets the removal time of the item
	 * @return returns the exitTime
	 */
	public String getExitTime()
	{
            if(exitTime == null)
            {
                return "";
            }
		return DateUtils.formatDateTime(exitTime.getTime());
	}
	
	public Calendar getExitTimeCal()
	{
            
		return exitTime;
	}

	/**
	 * gets the expiration date of the item
	 * @return returns the expiration date of the item
	 */
	public /*Calendar*/ String getExpirationDate()
	{
            if(expirationDate == null)
            {
                return "";
            }
		return DateUtils.formatDateTime(expirationDate.getTime());
	}

	/**
	 * gets the unique product id assigned to this item
	 * @return returns the unique product id
	 */
	public int getProductID()
	{
		return productID;
	}

	/**
	 * gets the product container id in which this item resides
	 * @return returns the product container id
	 */
	public int getParentContainerID()
	{
		return parentContainerID;
	}
	
	public void setParentID(int id)
	{
		parentContainerID = id;
	}
        
        /**
         * returns the removed boolean
         * @return boolean if item was removed from the system
         */
        
        public boolean getRemoved()
        {
            return removed;
        }
}
